local skill = fk.CreateSkill {
  name = "lvshi__zhiji",
}

Fk:loadTranslationTable{
  ["lvshi__zhiji"] = "志继",
  [":lvshi__zhiji"] = "一名角色的回合结束时，若中央区内红色牌的数量等于黑色牌的数量，你可减1点体力上限，进行一个额外的回合，若你未受伤，你先卜算3。",

  ["$lvshi__zhiji1"] = "此身为薪，炬成灰亦昭大汉长明！",
  ["$lvshi__zhiji2"] = "维之一腔骨血，可驱驰来北马否？",
}

local DIY = require "packages/diy_utility/diy_utility"

skill:addEffect(fk.TurnEnd, {
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skill.name) then
      local ids = DIY.getCenterCards(player.room)
      local reds = #table.filter(ids, function(id) return Fk:getCardById(id).color == Card.Red end)
      local blacks = #table.filter(ids, function(id) return Fk:getCardById(id).color == Card.Black end)
      return reds == blacks
    end
  end,
  on_use = function(self, event, target, player, data)
    if not player:isWounded() then
      player.room:askForGuanxing(player, player.room:getNCards(3))
    end
    player.room:changeMaxHp(player, -1)
    player:gainAnExtraTurn()
  end,
})


return skill